//
// Parse.cpp for  in /home/goldbe_y//cpp/Maths/206observ
//
// Made by yoni goldberg
// Login   <goldbe_y@epitech.net>
//
// Started on  Mon May  2 15:13:56 2011 yoni goldberg
// Last update Wed May 18 17:13:52 2011 yoni goldberg
//

#include <cstdlib>

#include "Parse.hpp"
#include "convert.hpp"


std::string	epur(std::string tmp)
{
  int	i = 0;

  while (tmp[i])
    {
      if (tmp[i] == '\t')
	tmp[i] = ' ';
      i++;
    }
  return (tmp);
}

Parse::Parse(const std::string &str)
{
  int				ind = 0;
  std::string			temp;
  std::ifstream			file(str.c_str());

  getline(file, temp);
  string_to_var(line, temp);
  while (ind < line)
    {
      getline(file, temp);
      tab.push_back(epur(temp));
      ind++;
    }
  file.close();

  int	i = 0;
  while (i < line) (filltabs(tab[i++]));
}

Parse::~Parse()
{
}

std::vector<std::string>		&Parse::get_from_file()
{
  return (tab);
}

void		Parse::filltabs(const std::string &str)
{
  int		ind = 0;
  float		tmp;
  std::string	temp("");

  while (str[ind] == ' ') (ind++);
  while (str[ind] != '\0' && str[ind] != ' ') (temp += str[ind++]);
  string_to_var(tmp, temp);
  val.push_back(tmp);
}

